package com.hqz.springboot2.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;

/**
 * TODO
 *
 * @author hqz
 * @ClassName HelloController
 * @createTime 2022年01月11日 15:49:00
 */
@RestController
@Slf4j
@RequiredArgsConstructor
public class HelloController {

    //private final FastFileStorageClient fastFileStorageClient;
    //
    //@Value("${upload.base-url}")
    //private  String basePath;
    //
    //@GetMapping("hello")
    //public String helloWorld() {
    //    return "Hello world springboot2";
    //}

    //@GetMapping("helloWebflux")
    //public Mono<String> webflux() {
    //    log.info("进入webflux");
    //    Mono<String> stringMono = Mono.fromSupplier(this::createStr);
    //    log.info("退出webflux");
    //    return stringMono;
    //}

    //@GetMapping(value = "helloWebflux1", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    //public Flux<String> webflux1() {
    //    log.info("进入webflux");
    //    Flux<String> stringFlux = Flux.fromStream(IntStream.range(1, 5).mapToObj(i -> {
    //        try {
    //            TimeUnit.SECONDS.sleep(1);
    //        } catch (InterruptedException e) {
    //            log.error(e.getMessage(), e);
    //        }
    //        return "flux data -- " + i;
    //    }));
    //    log.info("退出webflux");
    //    return stringFlux;
    //}

    //private String createStr() {
    //    return "Hello world springboot2";
    //}
    //
    //@SneakyThrows
    //@PostMapping("uploadFile")
    //public String uploadFile(MultipartFile file) {
    //    String suffix = FileUtil.getSuffix(file.getOriginalFilename());
    //    // 上传文件并生成缩略图
    //    StorePath storePath = fastFileStorageClient.uploadImageAndCrtThumbImage(file.getInputStream(), file.getSize(), suffix, null);
    //    String path = basePath + storePath.getFullPath();
    //    log.info(path);
    //    return path;
    //}
}
